import 'package:badges/badges.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class MineOrderButton extends StatelessWidget {
  final String _name;
  final String _title;
  final int _badge;
  final Function _onTap;

  MineOrderButton({
    Key key,
    String name,
    String title,
    int badge,
    @required Function onTap,
  })  : _name = name ?? 'assets/images/mine/ic_pending_pay.png',
        _title = title ?? '未设置',
        _badge = badge ?? 0,
        _onTap = onTap,
        super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWell(
      child: Badge(
        badgeContent: Text(
          '$_badge',
          style: TextStyle(color: Colors.white),
        ),
        badgeColor: Theme.of(context).accentColor,
        child: SizedBox(
          height: 50,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              Image.asset(_name, width: 28.w),
              Text(_title, style: TextStyle(fontSize: 12)),
            ],
          ),
        ),
        showBadge: _badge > 0,
      ),
      onTap: _onTap,
    );
  }
}
